<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
		<script src="../js/vue.js"></script>
	</head>

	<body>
		<div id="app">
			<cpn ref="aaa"></cpn>
		</div>
		<template id="cpn">
			<div>
				<div>
					cpn
				</div>
				<ccpn></ccpn>
			</div>
		</template>
		<template id="ccpn">
			<div>
				<div>
					我是子组件
				</div>
				<button @click="btnClick">点击</button>
			</div>
		</template>
	</body>
	<script>
		const app = new Vue({
			el: '#app',
			data: {
				message: '你好啊'
			},
			components: {
				cpn: {
					template: '#cpn',
					data(){
						return {
							name:'我是cpn组件'
						}
					},
					components:{
						ccpn: {
							template: "#ccpn",
							methods: {
								btnClick(){
									console.log(this.$parent);
									console.log(this.$root);
								}
							}
						}
					}
				}
			}
		});
	</script>

</html>
